home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / gettext / intl / plural-exp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2010-09-19  |  4.1 KB  |  130 lines

  1. /* Expression parsing and evaluation for plural form selection.
  2.    Copyright (C) 2000-2003, 2005-2007 Free Software Foundation, Inc.
  3.    Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
  4.  
  5.    This program is free software; you can redistribute it and/or modify it
  6.    under the terms of the GNU Library General Public License as published
  7.    by the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Library General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU Library General Public
  16.    License along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  18.    USA.  */
  19.  
  20. #ifndef _PLURAL_EXP_H
  21. #define _PLURAL_EXP_H
  22.  
  23. #ifndef internal_function
  24. # define internal_function
  25. #endif
  26.  
  27. #ifndef attribute_hidden
  28. # define attribute_hidden
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35.  
  36. enum expression_operator
  37. {
  38.   /* Without arguments:  */
  39.   var,                /* The variable "n".  */
  40.   num,                /* Decimal number.  */
  41.   /* Unary operators:  */
  42.   lnot,                /* Logical NOT.  */
  43.   /* Binary operators:  */
  44.   mult,                /* Multiplication.  */
  45.   divide,            /* Division.  */
  46.   module,            /* Modulo operation.  */
  47.   plus,                /* Addition.  */
  48.   minus,            /* Subtraction.  */
  49.   less_than,            /* Comparison.  */
  50.   greater_than,            /* Comparison.  */
  51.   less_or_equal,        /* Comparison.  */
  52.   greater_or_equal,        /* Comparison.  */
  53.   equal,            /* Comparison for equality.  */
  54.   not_equal,            /* Comparison for inequality.  */
  55.   land,                /* Logical AND.  */
  56.   lor,                /* Logical OR.  */
  57.   /* Ternary operators:  */
  58.   qmop                /* Question mark operator.  */
  59. };
  60.  
  61. /* This is the representation of the expressions to determine the
  62.    plural form.  */
  63. struct expression
  64. {
  65.   int nargs;            /* Number of arguments.  */
  66.   enum expression_operator operation;
  67.   union
  68.   {
  69.     unsigned long int num;    /* Number value for `num'.  */
  70.     struct expression *args[3];    /* Up to three arguments.  */
  71.   } val;
  72. };
  73.  
  74. /* This is the data structure to pass information to the parser and get
  75.    the result in a thread-safe way.  */
  76. struct parse_args
  77. {
  78.   const char *cp;
  79.   struct expression *res;
  80. };
  81.  
  82.  
  83. /* Names for the libintl functions are a problem.  This source code is used
  84.    1. in the GNU C Library library,
  85.    2. in the GNU libintl library,
  86.    3. in the GNU gettext tools.
  87.    The function names in each situation must be different, to allow for
  88.    binary incompatible changes in 'struct expression'.  Furthermore,
  89.    1. in the GNU C Library library, the names have a __ prefix,
  90.    2.+3. in the GNU libintl library and in the GNU gettext tools, the names
  91.          must follow ANSI C and not start with __.
  92.    So we have to distinguish the three cases.  */
  93. #ifdef _LIBC
  94. # define FREE_EXPRESSION __gettext_free_exp
  95. # define PLURAL_PARSE __gettextparse
  96. # define GERMANIC_PLURAL __gettext_germanic_plural
  97. # define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
  98. #elif defined (IN_LIBINTL)
  99. # define FREE_EXPRESSION libintl_gettext_free_exp
  100. # define PLURAL_PARSE libintl_gettextparse
  101. # define GERMANIC_PLURAL libintl_gettext_germanic_plural
  102. # define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
  103. #else
  104. # define FREE_EXPRESSION free_plural_expression
  105. # define PLURAL_PARSE parse_plural_expression
  106. # define GERMANIC_PLURAL germanic_plural
  107. # define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
  108. #endif
  109.  
  110. extern void FREE_EXPRESSION (struct expression *exp)
  111.      internal_function;
  112. extern int PLURAL_PARSE (void *arg);
  113. extern struct expression GERMANIC_PLURAL attribute_hidden;
  114. extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
  115.                        const struct expression **pluralp,
  116.                        unsigned long int *npluralsp)
  117.      internal_function;
  118.  
  119. #if !defined (_LIBC) && !defined (IN_LIBINTL) && !defined (IN_LIBGLOCALE)
  120. extern unsigned long int plural_eval (const struct expression *pexp,
  121.                       unsigned long int n);
  122. #endif
  123.  
  124.  
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128.  
  129. #endif /* _PLURAL_EXP_H */
  130.